//
//  PHPhotoLibrary+CustomPhotoAlbum.h
//  PHAsset_CustomPhotoAlbum
//
//  Created by jiangxk on 16/3/3.
//  Copyright © 2016年 蒋先科. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Photos/Photos.h>

typedef void(^PHAssetLibraryWriteImageCompletionBlock)(PHAsset *imageAsset);

typedef void(^PHAssetLibraryWriteVideoCompletionBlock)(NSURL *videoUrl);

typedef void(^PHAssetLibraryAccessFailureBlock)(NSError *error);

@interface PHPhotoLibrary (Save)

/**
 创建相册

 @param albumName 相册名称
 @return 相册
 */
- (PHAssetCollection *)omt_createAlbum:(NSString *)albumName;


/**
 保存一个UIImage对象到某一个相册里，若没有该相册会先自动创建

 @param image 图片
 @param albumName 相册名
 @param completion 成功
 @param failure 失败
 */
- (void)omt_saveImage:(UIImage *)image album:(NSString *)albumName completion:(PHAssetLibraryWriteImageCompletionBlock)completion failure:(PHAssetLibraryAccessFailureBlock)failure;

/**
 *  通过一个图片的本地url保存该图片到某一个相册里
 *
 *  @param imageUrl 图片路径
 *  @param albumName 相册名称
 *  @param completion 成功
 *  @param failure 失败
 */
- (void)omt_saveImageWithImageUrl:(NSURL *)imageUrl album:(NSString *)albumName completion:(PHAssetLibraryWriteImageCompletionBlock)completion failure:(PHAssetLibraryAccessFailureBlock)failure;

/**
 *  通过一个视频的本地url保存该视频到某一个相册里
 *
 *  @param videoUrl 视频路径
 *  @param albumName 相册名称
 *  @param completion 成功
 *  @param failure 失败
 */
- (void)omt_saveVideoWithUrl:(NSURL *)videoUrl album:(NSString *)albumName completion:(PHAssetLibraryWriteVideoCompletionBlock)completion failure:(PHAssetLibraryAccessFailureBlock)failure;

/**
 *  保存一个imageData对象到某一个相册里
 *
 *  @param imageData 图片二进制
 *  @param albumName 相册名称
 *  @param completion 成功
 *  @param failure 失败
 */
- (void)omt_saveImageData:(NSData *)imageData album:(NSString *)albumName completion:(PHAssetLibraryWriteImageCompletionBlock)completion failure:(PHAssetLibraryAccessFailureBlock)failure;


@end
